<template>
  <div class="container" style="width: 100%;height: 100%">

    <iframe class="iframe" id="myIframe" name="myIframe" ref="myIframe" src="/bigData/index2.html" frameborder="0" style="width: 100%;height: 99.6vh"></iframe>

  </div>
</template>

<script>
  import { getRukuData,getChukuData,getDpBb } from "@/api/bigScreen/dp";
  //import { mainListChukuInfo,listChukuInfo} from "@/api/business/chukuInfo";
  import { listCcStockInfo } from "@/api/business/ccStockInfo";
  export default {
    name: 'Index',
    data() {
      return {
        formDate:{},
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10000,
          rukuDate:'',
          state: '',
        },
        queryParams2: {
          pageNum: 1,
          pageSize: 1000000,
          state: '',
        },
      }
    },
    mounted() {
      // 监听全屏事件
      document.addEventListener('fullscreenchange', this.handleFullScreenChange);
      document.addEventListener('webkitfullscreenchange', this.handleFullScreenChange);
    },
    created() {
      // const now = new Date();
      // const year = now.getFullYear();
      // const month = now.getMonth() + 1;
      // const date = now.getDate();
      // const nowDate = `${year}-${month}-${date}`
      // this.queryParams.rukuDate = nowDate
      // this.queryParams.chukuDate = nowDate
      const obj1 = {}
      getRukuData().then(res=>{
        const rkList = res.data
        obj1.rkList = rkList
        const mapFrame = this.$refs['myIframe']
        mapFrame.contentWindow.location.reload()
        if (mapFrame.attachEvent) {
          mapFrame.attachEvent('onload', function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          })
        } else {
          mapFrame.onload = function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          }
        }
      })
      getChukuData().then(res=>{
        const ckList = res.data
        obj1.ckList = ckList
        const mapFrame = this.$refs['myIframe']
        mapFrame.contentWindow.location.reload()
        if (mapFrame.attachEvent) {
          mapFrame.attachEvent('onload', function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          })
        } else {
          mapFrame.onload = function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          }
        }
      })
      getDpBb().then(res=>{
        let num = res.data
        obj1.num = num
      })
      listCcStockInfo(this.queryParams2).then(res=>{
        let data = res.rows
        // let qjList = data.filter((val,index,arr)=>{
        //   return val.kyNum < val.downLine
        // })
        obj1.qjList = data
        let jpres = data.filter((val,index,arr)=>{
          return val.className == '镜片类'
        })
        let jp = jpres.length
        let pzres = data.filter((val,index,arr)=>{
          return val.className == '喷嘴类'
        })
        let pz = pzres.length
        let fjres = data.filter((val,index,arr)=>{
          return val.className == '附件类'
        })
        let fj = fjres.length
        let jxres = data.filter((val,index,arr)=>{
          return val.className == '机械类'
        })
        let jx = jxres.length
        let dqres = data.filter((val,index,arr)=>{
          return val.className == '电器类'
        })
        let dq = dqres.length
        let arr = []
        arr[0] = jp
        arr[1] = pz
        arr[2] = fj
        arr[3] = jx
        arr[4] = dq
        obj1.zlList = arr
        const mapFrame = this.$refs['myIframe']
        mapFrame.contentWindow.location.reload()
        if (mapFrame.attachEvent) {
          mapFrame.attachEvent('onload', function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          })
        } else {
          mapFrame.onload = function () {
            const iframeWin = mapFrame.contentWindow
            iframeWin.postMessage(obj1, '*')
          }
        }
      })

    },
    methods: {
      handleFullScreenChange() {
        const isFullScreen = document.fullscreenElement || document.webkitFullscreenElement;
        if (isFullScreen) {
          // 进入全屏模式时的处理逻辑
          this.$store.dispatch('app/toggleSideBarHide', true);
          document.querySelector('.navbar').style.display = "none"
          document.querySelector('.tags-view-container').style.display = "none"
        } else {
          // 退出全屏模式时的处理逻辑
          this.$store.dispatch('app/toggleSideBarHide', false);
          document.querySelector('.navbar').style.display = ""
          document.querySelector('.tags-view-container').style.display = ""
        }
      },
      toggleFullScreen() {
        const elem = document.documentElement;
        if (elem.requestFullscreen) {
          elem.requestFullscreen();
        } else if (elem.mozRequestFullScreen) {
          elem.mozRequestFullScreen();
        } else if (elem.webkitRequestFullscreen) {
          elem.webkitRequestFullscreen();
        } else if (elem.msRequestFullscreen) {
          elem.msRequestFullscreen();
        }
      },
      getDate(){

      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
